<?php
while (list ($key, $val) = each ($_REQUEST))
 {
  $$key = $val;
 } 

include("funciones/setup.php");
conecta();
include("funciones/redimencion_img_principal.php");


if($accion=="SubirImagen"){
	
global $id;
$error = "";
	$msg = "";
	$fileElementName = 'file_foto1';
	if(!empty($_FILES[$fileElementName]['error']))
	{
		switch($_FILES[$fileElementName]['error'])
		{

			case '1':
				$error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
				break;
			case '2':
				$error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
				break;
			case '3':
				$error = 'The uploaded file was only partially uploaded';
				break;
			case '4':
				$error = 'No file was uploaded.';
				break;

			case '6':
				$error = 'Missing a temporary folder';
				break;
			case '7':
				$error = 'Failed to write file to disk';
				break;
			case '8':
				$error = 'File upload stopped by extension';
				break;
			case '999':
			default:
				$error = 'No error code avaiable';
		}
	}elseif(empty($_FILES['file_foto1']['tmp_name']) || $_FILES['file_foto1']['tmp_name'] == 'none')
	{
		$error = 'No file was uploaded..';
	}else 
	{
	$nombre = $HTTP_POST_FILES['file_foto1']['name'];
	$tipo_archivo_dcto = $HTTP_POST_FILES['file_foto1']['type'];
	$tamano_archivo_dcto = $HTTP_POST_FILES['file_foto1']['size'];
	$userfile_tmp = $HTTP_POST_FILES['file_foto1']['tmp_name'];
	
	img_normal($nombre,$tipo_archivo_dcto,$tamano_archivo_dcto,$userfile_tmp,$id);
  
    $msg.="Archivo de Imagen Subido Con Exito";	
	}		
	echo "{";
	echo				"error: '" .$error. "',\n";
	echo				"msg: '" . $msg . "'\n";
	echo "}";
}
?>